<?php
include_once("./function.php");
//print_r($_POST);die;//Array ( [title] => 静夜思 [uname] => bv [content] => 李白 [text] => text [sub] => 添加 )
//映射
extract($_POST);//$title $uname $content  $text            $textarea
//数据处理
$title=trim($title);
$uname=trim($uname);
$content=trim($content);
if(empty($title)||empty($uname)||empty($content))
{
	msg("配置项标题,名称,内容不能为空","./sys_conf.php");
}
//判断添加名称是否已存在
$sql="select * from ts_sysconfig where sys_name='$uname'";
$res=mysqli_query($link,$sql);
if(is_object($res))
{
	if(mysqli_num_rows($res)>1)
	{
		msg("名称不能重复","sys_conf.php");exit;
	}
}

//添加内容入库
$sql="insert into ts_sysconfig(sys_title,sys_name,sys_val,sys_type) values('$title','$uname','$content','$text')";
//echo $sql;die;
$res=mysqli_query($link,$sql);
if($res)
{
	if(mysqli_affected_rows($link)==1)
	{
		msg("添加成功","sys_conf.php");exit;
	}
	else
	{
		msg("添加失败","sys_conf.php");exit;
	}

}
else
{
	echo "错误码:".mysqli_errno($link)."错误信息:".mysqli_error($link);exit;
}

?>